package com.itheima.bos.web.action;

import java.io.IOException;
import java.util.List;

import com.itheima.bos.domain.Role;
import com.itheima.bos.service.IRoleService;
import com.itheima.bos.web.action.base.BaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
/**
 * 角色管理Action
 */
@Controller
@Scope("prototype")
public class RoleAction extends BaseAction<Role> {

	@Autowired
	private IRoleService roleService;

	private String functionIds;
	public void setFunctionIds(String functionIds) {
		this.functionIds = functionIds;
	}

	/**
	 * 保存角色
	 */
	public String save(){
		roleService.save(model,functionIds);
		return "list";
	}
	
	/**
	 * 查询所有角色
	 */
	public String list() throws IOException {
		List<Role> list = roleService.findAll();
		String[] excludes = new String[]{"users","functions"};
		toJSON(list,excludes);
		return NONE;
	}
	
}
